 /**********************
 * Matthew Tanner
 * tannerm.onid.orst.edu
 * CS362
 * Assignment #3 unittest3.c
 * Tests the discardCard function in dominion.c
 ***********************/

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include <math.h>
#include "rngs.h"
#include "tests.h"
 
void unittest3(){

	//set minimum required variables
	struct gameState g;
	int players = 2;
	int k[10] = {adventurer, council_room, sea_hag, gardens, mine, remodel, smithy, village, baron, great_hall};
	int seed = 100;
	int res, numPlayerCards, player, trashflag, handpos;	

	//initialize game
	res = initializeGame(players, k, seed, &g);

	printf("Testing discardCard:\n");

	// Check initial state of player and play decks.
	printf("Initial playerhand: %d, playedcards %d:\n",g.handCount[player] ,g.playedCardCount);
	player = whoseTurn(&g);
	handpos = 0;
	
	//Condition #1, trashFlag set (card not added to played cards)
	trashflag = 1; //trash the card
	printf("Trashing card\n");
	res = discardCard(handpos, player, &g, trashflag);
	printf("Playerhand expected: 4, actual: %d\n", g.handCount[player]);
	printf("Playedcards expected: 0, actual: %d:\n", g.playedCardCount);
	assert(g.handCount[player] == 4);
	assert(g.playedCardCount == 0);

	//Condition #2, trashFlag set (card added to played cards)
	trashflag = 0;
	printf("Discarding card\n");
	res = discardCard(handpos, player, &g, trashflag);
	printf("Playerhand expected: 3, actual: %d\n", g.handCount[player]);
	printf("Playedcards expected: 1, actual: %d:\n", g.playedCardCount);
	assert(g.handCount[player] == 3);
	assert(g.playedCardCount == 1);

}